import request from './request'

export const userApi = {
  // 分页查询用户
  pageUsers(params) {
    return request.get('/system/user/page', { params })
  },
  
  // 获取用户详情
  getUserById(id) {
    return request.get(`/system/user/${id}`)
  },
  
  // 创建用户
  createUser(data) {
    return request.post('/system/user', data)
  },
  
  // 更新用户
  updateUser(data) {
    return request.put('/system/user', data)
  },
  
  // 删除用户
  deleteUser(id) {
    return request.delete(`/system/user/${id}`)
  },
  
  // 批量删除用户
  deleteBatchUsers(ids) {
    return request.delete('/system/user/batch', { data: ids })
  },
  
  // 分配角色
  assignRoles(userId, roleIds) {
    return request.post(`/system/user/${userId}/roles`, roleIds)
  },
  
  // 重置密码
  resetPassword(userId, newPassword) {
    return request.post(`/system/user/${userId}/reset-password`, null, {
      params: { newPassword }
    })
  },
  
  // 获取用户权限
  getUserPermissions(userId) {
    return request.get(`/system/user/${userId}/permissions`)
  }
}